home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Essential Home & Business Collection
/
The Essential Home & Business Collection.iso
/
27
/
3
/
5
/
HP22D5.ZIP
/
EXTERN
/
RUNABS.C
< prev
next >
Wrap
Text File
|
1991-04-16
|
2KB
|
75 lines
#include <dos.h>
#include "extern.h" /* Extensions need these! */
extern pascal far clearbuf();
pascal near value(char c)
{
if (c >= '0' && c <= '9') return(c - '0');
if (c >= 'a' && c <= 'f') return(c - 'a' + 10);
if (c >= 'A' && c <= 'F') return(c - 'A' + 10);
}
/*
** RUNABS
**
** This handler calls an absolute ROM address. The passed address takes the
** form SEGMENT:OFFSET, for example: F000:200. The address is converted to
** an internal representation and called just like any other routine. It is
** the responsibility of the ROM routine to preserve all of the registers
** that it modifies and to return via a normal retf instruction.
**
** The routine performs the following steps:
**
** 1. convert the address to internal format
** 2. Release HyperPAD's interrupts, providing a well behaved environment
** 3. Call the absolute address routine
** 4. Clear the keyboard buffer (some ROM routines incorrectly do this)
** 5. Restore HyperPAD, including the screen mode
** 6. Return to HyperPAD
**
** Example:
**
** runabs f000:200;
*/
runabs(int NumArgs,HANDLE hAddress)
{
PTR p,s;
register int i,n;
WORD w;
RTN rtn;
if (NumArgs != 1) return(STOP);
for (s=p=deref(hAddress);*s && *s != ':';s++);
for (i=s-p-1,w=0;i>= 0;i--) w |= value(*p++) << (i*4);
FP_SEG(rtn) = w;
for (p=++s;*s;s++);
for (i=(s-p)-1,w=0;i>= 0;i--) w |= value(*p++) << (i*4);
FP_OFF(rtn) = w;
ReleaseHPAD();
(*rtn)();
clearbuf();
RestoreHPAD();
return(STOP);
}
POOL pascal Pool[] = {
{ "runabs", /* name of the handler */
runabs, /* pointer to the handler */
0, /* reserved */
HANDLER}, /* this is a handler, not a function */
{ NULL, /* NULLs signify the end of the table */
NULL,
0,
0} };